State

Row

Chart 1

Comparison of the number of victims of various crimes in each state in the same year

Comparison of the number of victims of various crimes in each state in the same year

Row

Chart 2

Rate of change in the number of victims of various crimes by state

Rate of change in the number of victims of various crimes by state

Chart 3

Ten-year rate of change in the number of victims of various crimes by state
State robbery_rate robbery_change Sexual assault_rate Sexual assault_change Murder_rate Murder_change
Capital -19.867550 -30 69.430052 134 -100.000000 -3
NewSouthWales -43.953488 -945 51.451369 3740 4.109589 3
Northern Territory 43.478261 20 7.926829 26 -9.090909 -1
Queensland 73.246753 564 14.626091 620 -2.083333 -1
South Australia -34.482759 -180 13.719736 187 -33.333333 -5
Tasmania 1.176471 1 9.604520 17 -33.333333 -2
Victoria 40.751043 586 60.622761 2200 19.148936 9
Western Australia 13.358071 72 67.412334 1115 -10.000000 -3
Ten-year rate of change in the number of victims of various crimes by state
State extortion_rate extortion_change Manslaughter_rate Manslaughter_change Kidnapping_rate Kidnapping_change
Capital Inf 6 NaN 0 Inf 7
NewSouthWales -46.24277 -80 18.18182 2 -31.610942 -104
Northern Territory Inf 3 -100.00000 -3 NaN 0
Queensland 108.69565 50 -57.14286 -4 -13.235294 -9
South Australia 96.77419 30 NaN 0 -9.230769 -6
Tasmania NaN 0 NaN 0 Inf 3
Victoria 43.06569 59 366.66667 11 36.206897 42
Western Australia 20.00000 18 0.00000 0 21.052632 4

Row

Chart 4

The rate of change in the rate of various crime victims by state

The rate of change in the rate of various crime victims by state

Chart 5

A 10-year change in the proportion of victims of sexual assault
State 2010-2011 rate_change
NewSouthWales 34.4 33.8249754
Victoria 21.9 32.9323308
Queensland -0.8 -0.8316008
South Australia 4.7 5.6085919
Western Australia 33.4 46.2603878
Tasmania 1.5 4.3103448
Northern Territory 23.3 43.7148218
Capital 23.3 43.7148218

Gender

Column

Total number by gender

Analysis

  • On the whole, it shows an upward trend year by year recently.

  • The number of female victims is much higher than that of male victims, almost twice.

  • With the exception of sexual assault and kidnapping, the majority of victims are men.

  • The vast majority of cases are sexual assaults.

  • The number of robberies among the remaining crime categories is also considerable. (Including both armed and unarmed)

  • Possible reasons:

    • Women generally have stronger safety awareness
    • Women are less likely to be seen alone at night in areas where they are likely to be robbed

According to statistics of gender-specific crimes in various countries, male victims are the majority in almost all crimes except for sex-related crimes in which more women are victims.

Column

Number by gender by crime type

Sexual assault proportion

Sexual Assault Rate
Gender Year sa_rate
Female 2010 81.14353
Female 2011 80.92590
Female 2012 81.71220
Female 2013 83.46100
Female 2014 85.77439
Female 2015 87.63073
Female 2016 87.29571
Female 2017 88.86702
Female 2018 88.74093
Female 2019 87.99638
Male 2010 21.67991
Male 2011 23.79634
Male 2012 27.87459
Male 2013 30.70995
Male 2014 34.46328
Male 2015 38.35306
Male 2016 38.22735
Male 2017 39.55563
Male 2018 35.52154
Male 2019 33.06397

Take sexual assault, female victims of sexual assault make up a very high proportion of total female victims.

Column

Rate by gender

Analysis

  • Rate is calculated by victim number divided by 100,000 persons.
  • Show an upward pattern over years.
  • Higher than 0.15% in recent years which means 3 out of every 2,000 people have been sexually assaulted.
  • Possible reasons:
    • Women are physically vulnerable
    • Men are more sexually impulsive
    • Many women may choose not to report the crime
      • relationship to the offender
      • confidence in the justice system
      • fear of revenge
      • public opinion

ABS personal safety survey also measures the number of women who contacted the police about the most recent incident within the last 10 years. Only 13.4% of women did so.

Age

---
title: "Report"
author:
- familyname: Wang
  othernames: Yiru
  address: Monash Universtidy
  email: "ywan0553@student.monash.edu"
  correspondingauthor: true
  qualifications: section1
- familyname: Xu
  othernames: Kexin
  address: Monash University
  email: "kxuu0029@student.monash.edu"
  qualifications: section2
  correspondingauthor: true
- familyname: Tang
  othernames: Ruiqi
  address: Monash University
  email: "rtan00062student.monash.edu"
  correspondingauthor: true
  qualifications: section3
output: 
  flexdashboard::flex_dashboard:
    orientation: rows
    vertical_layout: scroll
    source_code: embed
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(fig.align = "center")
```



```{r, echo = FALSE, message = FALSE, warning = FALSE}
# Libraries
library(flexdashboard)
library(tinytex)
library(gridExtra)
library(tidyverse)
library(readr)
library(bookdown)
library(knitr)
library(plotly)
library(kableExtra)
library(readxl)
```

State {data-icon="fa-globe"}
=============================
 

Row {data-height=1000}
-------------------------------------
    
### Chart 1

```{r NewSouthWales}
NewSouthWales <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 3,range = "A5:AB30")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "NewSouthWales")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```

```{r NewSouthWales-rate,message=FALSE}
NewSouthWales_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 3,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
  mutate(State = "NewSouthWales")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```



```{r Victoria}
Victoria <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 4,range = "A5:AB28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "Victoria")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```

```{r Victoria_rate,message=FALSE}
Victoria_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 4,range = "A29:AB37")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
 mutate(State = "Victoria")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```



```{r Queensland}
Queensland <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 5,range = "A5:AB28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "Queensland")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```

```{r Queensland_rate,message=FALSE}
Queensland_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 5,range = "A29:AB37")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
  mutate(State = "Queensland")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```



```{r South_Australia}
South_Australia <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 6,range = "A5:AB30")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "South Australia")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```


```{r South_Australia_rate,message=FALSE}
South_Australia_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 6,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
mutate(State = "South Australia")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```


```{r Western_Australia}
Western_Australia <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 7,range = "A5:AB30")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "Western Australia")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```

```{r Western_Australia_rate,message=FALSE}
Western_Australia_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 7,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
  mutate(State = "Western Australia")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```


```{r Tasmania1}
Tasmania1 <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", 
                       sheet = 8,range = "A5:AB22")%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))%>%
  select(!("1993":"2009"))%>%
  pivot_longer(cols = '2010':'2013',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(Count = as.double(Count))%>%
 mutate(State = "Tasmania")%>%
  select(Offence,Year,Count,State)
```

```{r Tasmania}
Tasmania2 <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", 
                       sheet = 8,range = "A5:AB22")%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))%>%
  select(!("1993":"2013"))%>%
  pivot_longer(cols = '2014':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
 mutate(State = "Tasmania")%>%
 select(Offence,Year,Count,State)
Tasmania <- bind_rows(Tasmania1,Tasmania2)
```

```{r Tasmania_rate1,message=FALSE}
Tasmania_rate1 <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 8,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))%>%
  pivot_longer(cols = '2010':'2013',  
               names_to = "Year",            
               values_to = "Rate") %>%
   mutate(Rate = as.double(Rate))%>%
 mutate(State = "Tasmania")%>%
  select(Offence,Year,Rate,State)
```

```{r Tasmania_rate,message=FALSE}
Tasmania_rate2 <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 8,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))%>%
  pivot_longer(cols = '2014':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
 mutate(State = "Tasmania")%>%
  select(Offence,Year,Rate,State)
Tasmania_rate <- bind_rows(Tasmania_rate1,Tasmania_rate2)
```


```{r Northern_Territory}
Northern_Territory <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 9,range = "A5:AB30")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "Northern Territory")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```

```{r Northern_Territory_rate,message=FALSE}
Northern_Territory_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 10,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
  mutate(State = "Northern Territory")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```


```{r Capital}
Capital <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 10,range = "A5:AB30")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Count") %>%
  mutate(State = "Capital")%>%
  select(Offence,Year,Count,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction","Armed robbery","	Unarmed robbery","Blackmail/extortion"))
```

```{r Capital_rate,message=FALSE}
Capital_rate <- read_excel("data/Victims_of_Crime_Extended_time_series.xls", sheet = 10,range = "A31:AB41")%>%
  rename("Offence"= "...1","2010" = "...19" , "2011" = "...20","2012" = "...21","2013"="...22","2014"="...23","2015"="...24","2016"="...25","2017"="...26","2018"="...27","2019"="...28")%>%
  pivot_longer(cols = '2010':'2019',  
               names_to = "Year",            
               values_to = "Rate") %>%
  mutate(State = "Capital")%>%
  select(Offence,Year,Rate,State)%>%
  filter(Offence %in%c("Murder","	
Attempted murder","Manslaughter","Sexual assault","Kidnapping/abduction"))
```


```{r State}
State <- bind_rows(NewSouthWales,Victoria,Queensland,South_Australia,Western_Australia,Tasmania,Northern_Territory,Capital)
```

```{r}
State_rate <- bind_rows(NewSouthWales_rate,Victoria_rate,Queensland_rate,South_Australia_rate,Western_Australia_rate,Tasmania_rate,Northern_Territory_rate,Capital_rate)
```


```{r plot1,fig.height = 9, fig.width=10,fig.cap="Comparison of the number of victims of various crimes in each state in the same year"}
State %>%
  ggplot(aes(x = Offence,
             y = Count,
             fill = State))+
  geom_bar(stat  = "identity", position = "dodge") + 
  ggtitle("Comparison of the number of victims of various crimes in each state in the same year") +
  facet_wrap(~Year, ncol = 1,scales= "free")
```

Row {data-height=1000}
-------------------------------------
    
### Chart 2

```{r plot2,fig.height = 8, fig.width=8, fig.cap="Rate of change in the number of victims of various crimes by state"}
State %>%
  ggplot(aes( x = Year,     
              y = Count, 
              color = Offence,
              group = Offence)) + 
  geom_line(stat = "identity")  +
  theme(axis.title.x =element_text(size=14), axis.title.y=element_text(size=14)) +
   ggtitle("Rate of change in the number of victims of various crimes by state") +
  facet_wrap(~State, ncol = 1,scales= "free")
```


### Chart 3

```{r}
State_count1<-State %>%
  filter(Offence == "Sexual assault")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Count)%>%
  mutate("Sexual assault_rate" = ((`2019` - `2010`)/`2010`)*100)%>%
  mutate("Sexual assault_change" = (`2019` - `2010`))%>%
  select(!`2010`:`2019`)
State_count2<-State %>%
  filter(Offence == "Murder")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Count)%>%
  mutate("Murder_rate" = ((`2019` - `2010`)/`2010`)*100)%>%
   mutate("Murder_change" = (`2019` - `2010`))%>%
  select(!`2010`:`2019`)
State_count3<-State %>%
  filter(Offence == "Armed robbery")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Count)%>%
  mutate("robbery_rate" = ((`2019` - `2010`)/`2010`)*100)%>%
   mutate("robbery_change" = (`2019` - `2010`))%>%
  select(!`2010`:`2019`)
State_count4<-State %>%
  filter(Offence == "Manslaughter")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Count)%>%
  mutate("Manslaughter_rate" = ((`2019` - `2010`)/`2010`)*100)%>%
  mutate("Manslaughter_change" = (`2019` - `2010`))%>%
  select(!`2010`:`2019`)
State_count5<-State %>%
  filter(Offence == "Kidnapping/abduction")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Count)%>%
  mutate("Kidnapping_rate" = ((`2019` - `2010`)/`2010`)*100)%>%
   mutate("Kidnapping_change" = (`2019` - `2010`))%>%
  select(!`2010`:`2019`)
State_count6<-State %>%
  filter(Offence == "Blackmail/extortion")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Count)%>%
  mutate("extortion_rate" = ((`2019` - `2010`)/`2010`)*100)%>%
    mutate("extortion_change" = (`2019` - `2010`))%>%
  select(!`2010`:`2019`)

```


```{r table1,fig.height = 4 , fig.width=6}
state_sum1<-merge(State_count1,State_count2, by= 'State')
state_sum<-merge(State_count3,state_sum1, by= 'State')
knitr::kable(state_sum,caption = 'Ten-year rate of change in the number of victims of various crimes by state',booktabs = TRUE)%>%
   kable_styling(bootstrap_options = c("striped", "hover"))
```

```{r table2}
state_sum2<-merge(State_count4,State_count5, by= 'State')
state_sum3<-merge(State_count6,state_sum2,by= 'State')
knitr::kable(state_sum3,caption = 'Ten-year rate of change in the number of victims of various crimes by state',booktabs = TRUE)%>%
   kable_styling(bootstrap_options = c("striped", "hover"))
```

Row {data-height=600}
-------------------------------------

### Chart 4
    
```{r plot3,fig.height = 5 ,fig.width=7,fig.cap="The rate of change in the rate of various crime victims by state"}
State_rate %>%
  filter(Offence == "Sexual assault")%>%
  ggplot(aes( x = Year,     
              y = Rate, 
              color = State,
              group = State)) + 
  geom_line(stat = "identity")  +
  ylab("rate-Victims per 100,000")+
  theme(axis.title.x =element_text(size=14), axis.title.y=element_text(size=14)) +
   ggtitle("Rate of change in the number of victims of various crimes by state") 
```



### Chart 5
   
```{r table3}
State_rate1<-State_rate %>%
  filter(Offence == "Sexual assault")%>%
  pivot_wider(id_cols = State,  
              names_from = Year,  
              values_from = Rate)%>%
  mutate("2010-2011" = (`2019` - `2010`))%>%
  mutate("rate_change" =  ((`2019` - `2010`)/`2010`)*100)%>%
  select(!`2010`:`2019`)
 knitr::kable(
State_rate1, booktabs = TRUE,
  caption = 'A 10-year change in the proportion of victims of sexual assault')%>%
   kable_styling(bootstrap_options = c("striped", "hover"))
```
    


Gender {data-icon="fa-user-plus"}
==================
Column{data-width=400}
--------

### Total number by gender {data-width=350}
  
```{r echo=FALSE}
Victims_of_Crime_raw <- readxl::read_excel("data/Victims_of_Crime_Australia.xls", sheet = 3, skip = 4, col_names = FALSE)
Victims_of_Crime <- Victims_of_Crime_raw[-1,1:11]
colnames(Victims_of_Crime) = Victims_of_Crime[1,]
Victims_of_Crime <- Victims_of_Crime[-1,]
Homicide <- Victims_of_Crime[-1,] %>% 
  slice(c(1:18)) %>% 
  filter(`Sex and age` == "Total")
Homicide[1,1] <- "Homicide_Male"
Homicide[2,1] <- "Homicide_Female"
Homicide[3,1] <- "Homicide_All"
Homicide <- Homicide %>% rename("Type_Gender" = `Sex and age`)
Murder <- Victims_of_Crime %>% 
  slice(c(21:38)) %>% 
  filter(`Sex and age` == "Total")
Murder[1,1] <- "Murder_Male"
Murder[2,1] <- "Murder_Female"
Murder[3,1] <- "Murder_All"
Murder <- Murder %>% rename("Type_Gender" = `Sex and age`)
Attemptedmurder <- Victims_of_Crime %>% 
  slice(c(40:57)) %>% 
  filter(`Sex and age` == "Total")
Attemptedmurder[1,1] <- "Attemptedmurder_Male"
Attemptedmurder[2,1] <- "Attemptedmurder_Female"
Attemptedmurder[3,1] <- "Attemptedmurder_All"
Attemptedmurder <- Attemptedmurder %>% rename("Type_Gender" = `Sex and age`)
Manslaughter <- Victims_of_Crime %>% 
  slice(c(59:76)) %>% 
  filter(`Sex and age` == "Total")
Manslaughter[1,1] <- "Manslaughter_Male"
Manslaughter[2,1] <- "Manslaughter_Female"
Manslaughter[3,1] <- "Manslaughter_All"
Manslaughter <- Manslaughter %>% rename("Type_Gender" = `Sex and age`)
Sexualassault <- Victims_of_Crime %>% 
  slice(c(78:110)) %>% 
  filter(`Sex and age` == "Total")
Sexualassault[1,1] <- "Sexualassault_Male"
Sexualassault[2,1] <- "Sexualassault_Female"
Sexualassault[3,1] <- "Sexualassault_All"
Sexualassault <- Sexualassault %>% rename("Type_Gender" = `Sex and age`)
Kidnappingabduction <- Victims_of_Crime %>% 
  slice(c(112:141)) %>% 
  filter(`Sex and age` == "Total")
Kidnappingabduction[1,1] <- "Kidnappingabduction_Male"
Kidnappingabduction[2,1] <- "Kidnappingabduction_Female"
Kidnappingabduction[3,1] <- "Kidnappingabduction_All"
Kidnappingabduction <- Kidnappingabduction %>% rename("Type_Gender" = `Sex and age`)
Robbery <- Victims_of_Crime %>% 
  slice(c(143:175)) %>% 
  filter(`Sex and age` == "Total")
Robbery[1,1] <- "Robbery_Male"
Robbery[2,1] <- "Robbery_Female"
Robbery[3,1] <- "Robbery_All"
Robbery <- Robbery %>% rename("Type_Gender" = `Sex and age`)
Armedrobbery <- Victims_of_Crime %>% 
  slice(c(177:209)) %>% 
  filter(`Sex and age` == "Total")
Armedrobbery[1,1] <- "Armedrobbery_Male"
Armedrobbery[2,1] <- "Armedrobbery_Female"
Armedrobbery[3,1] <- "Armedrobbery_All"
Armedrobbery <- Armedrobbery %>% rename("Type_Gender" = `Sex and age`)
Unarmedrobbery <- Victims_of_Crime %>% 
  slice(c(211:243)) %>% 
  filter(`Sex and age` == "Total")
Unarmedrobbery[1,1] <- "Unarmedrobbery_Male"
Unarmedrobbery[2,1] <- "Unarmedrobbery_Female"
Unarmedrobbery[3,1] <- "Unarmedrobbery_All"
Unarmedrobbery <- Unarmedrobbery %>% rename("Type_Gender" = `Sex and age`)
Blackmailextortion <- Victims_of_Crime %>% 
  slice(c(245:274)) %>% 
  filter(`Sex and age` == "Total")
Blackmailextortion[1,1] <- "Blackmailextortion_Male"
Blackmailextortion[2,1] <- "Blackmailextortion_Female"
Blackmailextortion[3,1] <- "Blackmailextortion_All"
Blackmailextortion <- Blackmailextortion %>% rename("Type_Gender" = `Sex and age`)
Victims_of_Crime_tidy <- bind_rows(Homicide, Murder, Attemptedmurder, Manslaughter, Sexualassault, Kidnappingabduction, Robbery, Armedrobbery, Unarmedrobbery, Blackmailextortion) %>% 
  mutate(`2010` = as.numeric(`2010`)) %>% 
  pivot_longer(cols = -Type_Gender, 
               names_to = "Year",
               values_to = "Number") %>% 
  separate(col = Type_Gender,
           into = c("Type", "Gender"), "_") %>% 
  filter(!Type == "Homicide",
         !Type == "Robbery")
```

```{r echo=FALSE}
g <- Victims_of_Crime_tidy %>% 
  group_by(Year, Gender) %>%
  summarise(sum = sum(Number)) %>% 
  ggplot(aes(x = Year,
             y = sum,
             color = Gender,
             group = Gender)) +
  geom_line() +
  theme_bw() +
  scale_color_brewer(palette = "Dark2") + 
  theme(legend.position = "bottom")
ggplotly(g)
```


### Analysis{data-width=250}  
  
* On the whole, it shows an upward trend year by year recently.  
* The number of female victims is much higher than that of male victims, almost twice.  

* With the exception of sexual assault and kidnapping, the majority of victims are men.
* The vast majority of cases are sexual assaults.  
* The number of robberies among the remaining crime categories is also considerable. (Including both armed and unarmed)  
* Possible reasons:
  + Women generally have stronger safety awareness
  + Women are less likely to be seen alone at night in areas where they are likely to be robbed  
    
According to statistics of gender-specific crimes in various countries, male victims are the majority in almost all crimes except for sex-related crimes in which more women are victims.
  



Column{data-width=400}
---------------


### Number by gender by crime type {data-width=400}

```{r fig.height = 8, echo=FALSE}
Victims_of_Crime_tidy %>% 
  ggplot() +
  geom_col(aes(x = Year,
                y = Number,
                fill = Gender),
           position = "dodge") +
  facet_grid(Type~., scales = "free_y") +
  scale_fill_brewer(palette = "Dark2") +
  theme_bw()
```




### Sexual assault proportion {data-width=450}



```{r echo=FALSE}
Victims_of_Crime_sum <- Victims_of_Crime_tidy %>% 
  filter(!Gender == "All") %>% 
  group_by(Gender, Year) %>% 
  summarise(sum = sum(Number))

Victims_of_Crime_tidy %>% 
  filter(Type == "Sexualassault" &
         !Gender == "All") %>% 
  left_join(Victims_of_Crime_sum) %>% 
  group_by(Gender, Year) %>% 
  summarise(sa_rate = Number/sum*100) %>% 
  kable(caption = "Sexual Assault Rate") %>%
  kable_styling(bootstrap_options = c("striped", "hover"))
```

Take sexual assault, female victims of sexual assault make up a very high proportion of total female victims.  

Column{data-width=400}
-----------

### Rate by gender{data-width=350}


```{r echo=FALSE}
Victims_of_Crime1 <- Victims_of_Crime_raw[-1,c(1, 12:21)]
colnames(Victims_of_Crime1) = Victims_of_Crime1[1,]
Victims_of_Crime1 <- Victims_of_Crime1[-1,]

Sexualassault1 <- Victims_of_Crime1 %>% 
  slice(c(78:110)) %>% 
  filter(`Sex and age` == "Total")
Sexualassault1[1,1] <- "Sexualassault_Male"
Sexualassault1[2,1] <- "Sexualassault_Female"
Sexualassault1[3,1] <- "Sexualassault_All"
Sexualassault1 <- Sexualassault1 %>% rename("Type_Gender" = `Sex and age`)

Sexualassault_rate <- Sexualassault1 %>% 
  mutate(`2010` = as.numeric(`2010`)) %>% 
  pivot_longer(cols = -Type_Gender, 
               names_to = "Year",
               values_to = "Rate") %>% 
  separate(col = Type_Gender,
           into = c("Type", "Gender"), "_") %>% 
  filter(!Gender == "All")
```


  

```{r echo=FALSE, fig.height=3, fig.width=5}
sa <- Sexualassault_rate %>%
  ggplot() +
  geom_col(aes(x = Year,
               y = Rate,
               fill = Gender),
               position = "dodge") +
  theme_bw() +
  scale_fill_brewer(palette = "Dark2") + 
  theme(legend.position = "bottom")

ggplotly(sa)
```
  
 
### Analysis 
  
* Rate is calculated by victim number divided by 100,000 persons.
* Show an upward pattern over years.
* Higher than 0.15% in recent years which means 3 out of every 2,000 people have been sexually assaulted.
* Possible reasons:
  + Women are physically vulnerable
  + Men are more sexually impulsive
  + Many women may choose not to report the crime
    - relationship to the offender
    - confidence in the justice system
    - fear of revenge
    - public opinion  
  
ABS personal safety survey also measures the number of women who contacted the police about the most recent incident within the last 10 years. Only 13.4% of women did so. 
   























Age {data-icon="fa-user-times"}
====================